<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: '队长',
            age: 16
        }
        let handel = {
            set: function (target, key, value) {
                console.log(target, key, value);
                if (value < 0) {
                    return
                }
                target[key] = value;
            },
            get: function (target, key) {
                console.log(target, key);
                return target[key];
            }
        }
        let proxy = new Proxy(obj, handel);
        console.log(proxy);
        proxy.age = 20;
        console.log(proxy);
        console.log(proxy.age);


        let obj1 = {
            x: 0,
            y: 0
        }
        let handel1 = {
            set: function (target, key, value) {
                if (value < 0) {
                    return
                }
                if (value > 100) {
                    return
                }
                target[key] = value;
            },
            get: function (target, key) {
                return target[key];
            }
        }
        obj1 = new Proxy(obj1, handel1);
        console.log(obj1);
        obj1.x = 123;
        obj1.y = 45;
        console.log(obj1);

        let obj2 = {
            name: '李四',
            age: 21
        }
        let valu = Reflect.get(obj2, 'name');
        console.log(valu);
        let age = Reflect.get(obj2, 'age');
        console.log(age);
        Reflect.set(obj2, 'name', '王五');
        Reflect.set(obj2, 'age', 81);
        console.log(obj2);


        let formdata = {
            account: 'admin',
            password: '123456'
        }
        let handel2 = {
            set: function (target, key, value) {
                if (value.length < 6 || value.length > 20) {
                    return
                }
                target[key] = value;
            },
            get: function (target, key) {
                console.log('get', target, key);
                return target[key];
            }
        }
        formdata = new Proxy(formdata, handel2);
        console.log(formdata);

        Reflect.set(formdata, 'account', 'admin12345');
        Reflect.set(formdata, 'account', 'adm');
        Reflect.set(formdata, 'password', '1111111111');
        console.log(formdata);
        let account = Reflect.get(formdata, 'account');
        let password = Reflect.get(formdata, 'password');
        console.log(account, password);

        let string = 'hello world';
        console.log(string.includes('hello', 1));
        console.log(string.includes('world', 3));
        console.log(string.startsWith('world'));
        console.log(string.endsWith('world'));
        console.log('hh'.padStart(6));
        console.log('hh'.padStart(6, 'l'));
        console.log('kk'.padEnd(6));
        console.log('kk'.padEnd(6, 'l'));

        console.log(Number.isNaN(NaN));
        console.log(Number.isNaN('jk' / 123));
        console.log(Number.isNaN(0));
        console.log(Number.isNaN('hello'));
        console.log(Number.isNaN('hhhhaaaa'));
        console.log(Number.isNaN(12345));
        console.log(Number.isNaN(null));
        console.log(Number.isNaN(undefined));

        console.log(parseInt('111', 2));
        console.log(parseInt('145', 8));
        console.log(parseInt('415', 10));
        console.log(parseInt('4544155', 16));

        let resule = ['1', '2', '3'].map(function (v, i) {
            return 'hello' + v;
        })
        console.log(resule);

        console.log(['1', '2', '3'].map(parseInt));
    </script>
</body>

</html>